From 2ff9ffb1de0b80cadbd8c9460b076bcf2d51bed6 Mon Sep 17 00:00:00 2001
From: Myy <myy@miouyouyou.fr>
Date: Mon, 5 Jun 2017 12:36:44 +0000
Subject: [PATCH 3/4] Enabling Tinkerboard's Wifi : Third tentative !

This time with modifications brought and tested by @TonyMac32 .
More informations in this thread :

https://forum.armbian.com/index.php?/topic/3327-asus-tinkerboard/&page=11

Signed-off-by: Myy <myy@miouyouyou.fr>
---
 arch/arm/boot/dts/rk3288-tinker.dts | 106 +++++++++++++++++++++++++++++++++++-
 1 file changed, 103 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boot/dts/rk3288-tinker.dts b/arch/arm/boot/dts/rk3288-tinker.dts
index f601c78..c7c793f 100644
--- a/arch/arm/boot/dts/rk3288-tinker.dts
+++ b/arch/arm/boot/dts/rk3288-tinker.dts
@@ -44,6 +44,7 @@
 
 #include "rk3288.dtsi"
 #include <dt-bindings/input/input.h>
+#include <dt-bindings/clock/rockchip,rk808.h>
 
 / {
 	model = "Rockchip RK3288 Tinker Board";
@@ -54,6 +55,18 @@
 		device_type = "memory";
 	};
 
+	/* Since wlan-platdata do NOT exist in this kernel,
+	   I don't know if the 'compatible' part is really
+	   necessary... */
+	wireless-wlan {
+		compatible = "wlan-platdata";
+		rockchip,grf = <&grf>;
+		wifi_chip_type = "8723bs";
+		sdio_vref = <1800>;
+		WIFI,host_wake_irq = <&gpio4 30 GPIO_ACTIVE_HIGH>;
+		status = "okay";
+	};
+	
 	ext_gmac: external-gmac-clock {
 		compatible = "fixed-clock";
 		#clock-cells = <0>;
@@ -134,6 +147,24 @@
 		startup-delay-us = <100000>;
 		vin-supply = <&vcc_io>;
 	};
+	
+	/* This is essential to get SDIO devices working.
+	   The Wifi depends on SDIO ! */
+	sdio_pwrseq: sdio-pwrseq {
+		compatible = "mmc-pwrseq-simple";
+		clocks = <&rk808 RK808_CLKOUT1>;
+		clock-names = "ext_clock";
+		pinctrl-names = "default";
+		pinctrl-0 = <&chip_enable_h>, <&wifi_enable_h>;
+
+		/*
+		 * On the module itself this is one of these (depending
+		 * on the actual card populated):
+		 * - SDIO_RESET_L_WL_REG_ON
+		 * - PDN (power down when low)
+		 */
+		reset-gpios = <&gpio4 RK_PD4 GPIO_ACTIVE_LOW>, <&gpio4 RK_PD3 GPIO_ACTIVE_LOW>;
+	};
 };
 
 &cpu0 {
@@ -197,7 +228,7 @@
 				regulator-always-on;
 				regulator-boot-on;
 				regulator-min-microvolt = <750000>;
-				regulator-max-microvolt = <1350000>;
+				regulator-max-microvolt = <1450000>;
 				regulator-name = "vdd_arm";
 				regulator-ramp-delay = <6000>;
 				regulator-state-mem {
@@ -333,7 +364,6 @@
 			};
 
 			vcc33_sd: SWITCH_REG1 {
-				regulator-always-on;
 				regulator-boot-on;
 				regulator-name = "vcc33_sd";
 				regulator-state-mem {
@@ -353,10 +383,22 @@
 	};
 };
 
+&i2c1 {
+	status = "okay";
+};
+
 &i2c2 {
 	status = "okay";
 };
 
+&i2c3 {
+	status = "okay";
+};
+
+&i2c4 {
+	status = "okay";
+};
+
 &i2c5 {
 	status = "okay";
 };
@@ -366,9 +408,46 @@
 	status = "okay";
 };
 
-&io_domains {
+&spi2 {
 	status = "okay";
+	max-freq = <50000000>;
+	spidev@0 {
+		compatible = "rockchip,spi_tinker";
+		reg = <0>;
+		spi-max-frequency = <50000000>;
+		spi-cpha = <1>;
+	};
+	spidev@1 {
+		compatible = "rockchip,spi_tinker";
+		reg = <1>;
+		spi-max-frequency = <50000000>;
+		spi-cpha = <1>;
+	};
+};
 
+&sdio0 {
+	status = "okay";
+	clock-frequency = <50000000>;
+	clock-freq-min-max = <200000 50000000>;
+	bus-width = <4>;
+	cap-sd-highspeed;
+	cap-sdio-irq;
+	disable-wp;
+	keep-power-in-suspend;
+	mmc-pwrseq = <&sdio_pwrseq>;
+	non-removable;
+	num-slots = <1>;
+	pinctrl-names = "default";
+	pinctrl-0 = <&sdio0_bus4 &sdio0_cmd &sdio0_clk>;
+	sd-uhs-sdr104;
+	supports-sdio;
+
+};
+
+&io_domains {
+	status = "okay";
+	rockchip,grf = <&grf>;
+	wifi-supply = <&vcc_18>;
 	sdcard-supply = <&vccio_sd>;
 };
 
@@ -417,6 +496,16 @@
 		};
 	};
 
+	sdio-pwrseq {
+		wifi_enable_h: wifienable-h {
+			rockchip,pins = <4 28 RK_FUNC_GPIO &pcfg_pull_none>;
+		};
+
+		chip_enable_h: chip-enable-h {
+			rockchip,pins = <4 27 RK_FUNC_GPIO &pcfg_pull_none>;
+		};
+	};
+	
 	sdmmc {
 		sdmmc_bus4: sdmmc-bus4 {
 			rockchip,pins = <6 16 RK_FUNC_1 &pcfg_pull_up_drv_8ma>,
@@ -448,6 +537,12 @@
 			rockchip,pins = <7 8 RK_FUNC_GPIO &pcfg_pull_none>;
 		};
 	};
+	
+	wireless-bluetooth {
+		uart0_gpios: uart0-gpios {
+			rockchip,pins = <4 19 RK_FUNC_GPIO &pcfg_pull_none>;
+		};
+	};
 };
 
 &pwm0 {
@@ -463,12 +558,17 @@
 	bus-width = <4>;
 	cap-mmc-highspeed;
 	cap-sd-highspeed;
+	sd-uhs-sdr12;
+	sd-uhs-sdr25;
+	sd-uhs-sdr50;
+	sd-uhs-sdr104;
 	card-detect-delay = <200>;
 	disable-wp;			/* wp not hooked up */
 	num-slots = <1>;
 	pinctrl-names = "default";
 	pinctrl-0 = <&sdmmc_clk &sdmmc_cmd &sdmmc_cd &sdmmc_bus4>;
 	status = "okay";
+	supports-sd;
 	vmmc-supply = <&vcc33_sd>;
 	vqmmc-supply = <&vccio_sd>;
 };
-- 
2.10.2

